package com.lineage.server.command.executor;

import com.lineage.config.Config;
import com.lineage.server.clientpackets.AcceleratorChecker;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import java.util.Calendar;
import java.util.TimeZone;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class L1SpeedCheck implements L1CommandExecutor {
  private static final Log _log = LogFactory.getLog(L1SpeedCheck.class);
  
  public static L1CommandExecutor getInstance() {
    return new L1SpeedCheck();
  }
  
  public Calendar getRealTime() {
    TimeZone _tz = TimeZone.getTimeZone(Config.TIME_ZONE);
    Calendar cal = Calendar.getInstance(_tz);
    return cal;
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    try {
      double set = AcceleratorChecker.CHECK_STRICTNESS = Double.parseDouble(arg);
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "设置防加速允许范围值" + set + "倍。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("设置防加速允许范围值" + set + "倍。"));
      } 
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
      if (pc == null) {
        _log.error("错误的命令格式: " + getClass().getSimpleName());
      } else {
        _log.error("错误的GM指令格式: " + getClass().getSimpleName() + " 执行的GM:" + pc.getName());
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(261));
      } 
    } 
  }
}
